*******************************************************************************************
* Aarøe, Petersen & Arceneaux 2020
* replication dofile for the results from the US 2014 congressional electtions sample 3
*******************************************************************************************

clear 
set more off

* use the following replication data set
use "Replication dataset for the US 2014 sample 3.dta"


*******************************************************************************************
* Recodings
*******************************************************************************************

* Germ aversion
recode  q1a_5 (7=1) (6=2) (5=3) (4=4) (3=5) (2=6) (1=7), gen (q1a_5rc)
recode  q1a_7 q1a_8 (7=1) (6=2) (5=3) (4=4) (3=5) (2=6) (1=7), gen (q1a_7rc q1a_8rc)

alpha  q1a_1 q1a_2 q1a_3 q1a_4 q1a_5rc q1a_6 q1a_7rc q1a_8rc

egen germ=rmean(q1a_1 q1a_2 q1a_3 q1a_4 q1a_5rc q1a_6 q1a_7rc q1a_8rc)
gen germ01=(germ-1)/6
ta germ01

* pathogen disgust sensitivity
alpha  q1b_1 q1b_2 q1b_3 q1b_4 q1b_5 q1b_6 q1b_7 
egen pathogen =rmean( q1b_1 q1b_2 q1b_3 q1b_4 q1b_5 q1b_6 q1b_7)
gen pathogen01=(pathogen-1)/6
ta pathogen01

* Contamination disgust sensitivity
alpha q1c_1 q1c_2 q1d_1 q1d_2 q1d_3
egen contamination = rmean (q1c_1 q1c_2 q1d_1 q1d_2 q1d_3)
gen contamination01=contamination/4
ta contamination01

egen combinedscale = rmean(contamination01 pathogen01 germ01)
alpha contamination01 pathogen01 germ01

*

*vote 2014 congressional elections 4-point
gen vote2014=.
replace vote2014 = 1 if q5 ==2
replace vote2014 = 2 if q6 ==2
replace vote2014 = 3 if q6 ==1
replace vote2014 = 4 if q5 ==1
gen vote201401 =(vote2014-1)/3

* vote 2014 congressional 2 point measure
gen dvote2014= . 
replace dvote2014 = 0 if q5 ==2
replace dvote2014 = 1 if q5 ==1

*vote 2010
gen vote2010=q7
recode vote2010 (1=1) (2=0) (3=.) (4=.) (5=.)


* party identification
gen pid7=.
replace pid7 = 7 if q9 ==1
replace pid7 = 6 if q9 ==2
replace pid7 = 1 if q10 ==1
replace pid7 = 2 if q10 ==2
replace pid7 = 5 if q11 ==1
replace pid7 = 3 if q11 ==2
replace pid7 = 4 if q8 == 3 & q11 ==3

gen pid701 = (pid7-1)/6


*ideology
gen ideo01=(q4-1)/6

*household income
gen houseincome =household_income
recode houseincome (97=.)
gen houseincome01 =(houseincome-1)/11


* female
gen female = gender-1

*education01
gen education01=(education-1)/5

*race
gen race5=race
recode race5 (1=1) (2=2) (3=3) (4=4) (5=5) (6=5) (7=5) (8=5)

egen openness=rmean(q6a_w2 q6b_w2)
egen conscient=rmean( q6c_w2 q6d_w2)
egen extraversion=rmean(q6e_w2 q6f_w2)
egen agreeableness= rmean(q6g_w2 q6h_w2) 
egen emotionalstability=rmean(q6i_w2 q6j_w2)
gen openness01=openness/10
gen conscient01=conscient/10
gen extraversion01=extraversion/10
gen agreeableness01=agreeableness/10
gen emotionalstability01=emotionalstability/10

gen neuroticism01=1-emotionalstability01

*****************************************************************************
* sample descriptives and analyses
*****************************************************************************

sum female
sum age 
ta education
ta household_income
ta race5

eststo clear
estpost tabstat combinedscale contamination01 pathogen01 germ01, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear

eststo clear
estpost tabstat pid701, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear

eststo clear
estpost tabstat dvote2014 vote2010, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear

eststo clear
estpost tabstat ideo01, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear

* Average marginal effects for Figure 1 in the main text
* The average marginal effects are also reported on Online Appendix A3.1.1
* the estimates were included in the dataset for the metaanalysis of effects of pathogen avoidance motivation on party preferences  
* party identification 
reg pid701 c.combinedscale education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90)
margins, dydx(combinedscale houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

reg pid701 c.contamination01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(contamination01 houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

reg pid701 c.pathogen01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(pathogen01 houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

reg pid701 c.germ01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(germ01 houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

* vote choice in the 2014 election
quietly probit dvote2014 c.combinedscale education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(combinedscale houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

quietly probit dvote2014 c.contamination01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(contamination01 houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

quietly probit dvote2014 c.pathogen01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(pathogen01 houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

quietly probit dvote2014 c.germ01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(germ01 houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

* vote choice in the 2010 election
probit vote2010 c.combinedscale education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(combinedscale houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

quietly probit vote2010 c.contamination01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(contamination01 houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

quietly probit vote2010 c.pathogen01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(pathogen01 houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 


quietly probit vote2010 c.germ01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(germ01 houseincome01 education01 openness01 conscient01 agreeableness01) level (90)


* results for table A9
eststo clear
foreach var of varlist  combinedscale contamination01 pathogen01 germ01 {
eststo: reg pid701 `var' female houseincome01 education01 age i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90)

}

foreach var of varlist  combinedscale contamination01 pathogen01  germ01 {
eststo: probit dvote2014 `var'  female houseincome01 education01 age i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90)

}

foreach var of varlist  combinedscale contamination01 pathogen01  germ01 {
eststo: probit vote2010 `var'  female houseincome01 education01 age i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90)

}
esttab, b(%5.2f) se(%5.2f), using example.rtf, replace onecell star(* 0.1 ** 0.02 *** 0.002) wide constant ar2 compress
eststo clear


* analyses of robustness for Figure 2 reported in the Online Appendix A3.2
* analyses with party identification
reg pid701 pathogen01 houseincome01 education01 age female  i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)

gen miss = e(sample)

reg pid701 houseincome01 education01 age female  i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01 if miss ==1, level (90)
margins, dydx(houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

reg pid701 education01 age female houseincome01 i.race5 if miss ==1 /*
*/, level (90)
margins, dydx(houseincome01 education01) level (90)


* analyses of robustness for figure 2 reported in the Online Appendix A3.2
* analyses with vote choice 2014
probit dvote2014 c.germ01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)

gen miss2=e(sample)

probit dvote2014 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01 if miss2 ==1, level (90)
margins, dydx(houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

probit dvote2014 education01 age female houseincome01 i.race5 /*
*/ if miss2 ==1, level (90)
margins, dydx(houseincome01 education01) level (90) 


* analyses of robustness for figure 2 reported in the Online Appendix A3.2
* analyses with vote choice 2014
probit vote2010 c.germ01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
gen miss3=e(sample)

probit vote2010 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01 if miss3 ==1, level (90)
margins, dydx(houseincome01 education01 openness01 conscient01 agreeableness01) level (90) 

probit vote2010 education01 age female houseincome01 i.race5 /*
*/ if miss3 ==1, level (90)
margins, dydx(houseincome01 education01) level (90) 

* analyses of robustness for Figure 2 - effect of BIS without Big Five personality traits in the model
* with party udentification
probit pid701 c.germ01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
gen miss4=e(sample)

probit pid701 c.combinedscale education01 age female houseincome01 i.race5 /*
*/ if miss4 ==1, level (90)
margins, dydx(combinedscale) level (90)

probit pid701 c.contamination01 education01 age female houseincome01 i.race5 /*
*/ if miss4 ==1, level (90)
margins, dydx(contamination01) level (90)

probit pid701 c.pathogen01 education01 age female houseincome01 i.race5 /*
*/ if miss4 ==1, level (90)
margins, dydx(pathogen01) level (90)

probit pid701 c.germ01 education01 age female houseincome01 i.race5 /*
*/ if miss4 ==1, level (90)
margins, dydx(germ01) level (90) 

* with vote choice 2014
probit dvote2014 c.germ01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
gen miss5=e(sample)

probit dvote2014 c.combinedscale education01 age female houseincome01 i.race5 /*
*/ if miss5 ==1, level (90)
margins, dydx(combinedscale) level (90)

probit dvote2014 c.contamination01 education01 age female houseincome01 i.race5 /*
*/ if miss5 ==1, level (90)
margins, dydx(contamination01) level (90)

probit dvote2014 c.pathogen01 education01 age female houseincome01 i.race5 /*
*/ if miss5 ==1, level (90)
margins, dydx(pathogen01) level (90)

probit dvote2014 c.germ01 education01 age female houseincome01 i.race5 /*
*/ if miss5 ==1, level (90)
margins, dydx(germ01) level (90) 

*with vote choice 2010
probit vote2010 c.germ01 education01 age female houseincome01 i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
gen miss6=e(sample)

quietly probit vote2010 c.combinedscale education01 age female houseincome01 i.race5 /*
*/ if miss6 ==1, level (90)
margins, dydx(combinedscale) level (90)

quietly probit vote2010 c.contamination01 education01 age female houseincome01 i.race5 /*
*/ if miss6 ==1, level (90)
margins, dydx(contamination01) level (90)

quietly probit vote2010 c.pathogen01 education01 age female houseincome01 i.race5 /*
*/ if miss6 ==1, level (90)
margins, dydx(pathogen01) level (90)

quietly probit vote2010 c.germ01 education01 age female houseincome01 i.race5 /*
*/ if miss6 ==1, level (90)
margins, dydx(germ01) level (90) 

* analyses for online appendix A3.3. Figure A3
foreach var of varlist  combinedscale contamination01 pathogen01  germ01 {
eststo: quietly reg ideo01 `var'  female houseincome01 education01 age i.race5 /*
*/ openness01 conscient01 extraversion01 agreeableness01 emotionalstability01, level (90)
margins, dydx(`var')

}

